//
//  TDNetwork.m
//  MovieDate
//
//  Created by ann on 16/3/18.
//  Copyright © 2016年 MovieDate. All rights reserved.
//

#import "TDNetwork.h"
#import "AFNetworking.h"
#import <CommonCrypto/CommonDigest.h>

@implementation TDNetwork

+(void)requestNetWorkURL:(NSString *)urlStr
              parameters:(id )parameters
                progress:(void (^)(NSProgress * _Nonnull))uploadProgress
                 success:(void (^)(NSURLSessionDataTask * _Nonnull, id _Nullable))success
                 failure:(void (^)(NSURLSessionDataTask * _Nullable, NSError * _Nonnull))failure
                complete:(void(^)(BOOL succeed, NSString * ret, NSDictionary * dictionary))complete
{

    NSURL *url = [NSURL URLWithString:urlStr];
    AFHTTPSessionManager *session = [AFHTTPSessionManager manager];
    session.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", @"text/html", nil];
 //设置cook
    if ([[NSUserDefaults standardUserDefaults] objectForKey:kUserDefaultsCookie]) {
        NSArray *cookies = [NSKeyedUnarchiver unarchiveObjectWithData:[[NSUserDefaults standardUserDefaults] objectForKey:kUserDefaultsCookie]];
        NSHTTPCookieStorage *cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
        for (NSHTTPCookie *cookie in cookies) {
            [cookieStorage setCookie:cookie];
        }
    }
    NSLog(@"进入网络请求 正式开始请求");
    [session POST:url.absoluteString parameters:parameters progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
 //获取并存储cook

        NSArray * cooks = [[NSHTTPCookieStorage sharedHTTPCookieStorage]cookies];
        NSData *cookiesData = [NSKeyedArchiver archivedDataWithRootObject:cooks];
        [[NSUserDefaults standardUserDefaults] setObject:cookiesData forKey:kUserDefaultsCookie];
        [[NSUserDefaults standardUserDefaults] synchronize];
        NSLog(@"网络请求成功");
        NSDictionary *dic = responseObject;
        NSString *ret =   [NSString stringWithFormat:@"%@",[dic valueForKey:@"ret"]] ;
        complete(YES,ret,dic);
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        NSString *errorCode = [NSString stringWithFormat:@"%@",error.description];
        NSLog(@"网络请求失败");
        complete(NO,errorCode,@{@"error":errorCode});
    }];
}

+ (void)requestGETNetWorkURL:(NSString *)urlStr
                 parameters:(NSDictionary *)parameters
                   complete:(void(^)(BOOL succeed, NSString * ret, NSDictionary * dictionary))complete{
    NSURL *url = [NSURL URLWithString:urlStr];
    
    AFHTTPSessionManager *session = [AFHTTPSessionManager manager];
    //设置cook
    if ([[NSUserDefaults standardUserDefaults] objectForKey:kUserDefaultsCookie]) {
        NSArray *cookies = [NSKeyedUnarchiver unarchiveObjectWithData:[[NSUserDefaults standardUserDefaults] objectForKey:kUserDefaultsCookie]];
        NSHTTPCookieStorage *cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
        for (NSHTTPCookie *cookie in cookies) {
            [cookieStorage setCookie:cookie];
        }
    }
    
    [session GET:url.absoluteString parameters:parameters progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        //获取并存储cook
        
        NSArray * cooks = [[NSHTTPCookieStorage sharedHTTPCookieStorage]cookies];
        NSData *cookiesData = [NSKeyedArchiver archivedDataWithRootObject:cooks];
        [[NSUserDefaults standardUserDefaults] setObject:cookiesData forKey:kUserDefaultsCookie];
        [[NSUserDefaults standardUserDefaults] synchronize];

        NSDictionary *dic = responseObject;
        NSString *ret =   [NSString stringWithFormat:@"%@",[dic valueForKey:@"ret"]] ;
        complete(YES,ret,dic);
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        NSString *errorCode = [NSString stringWithFormat:@"%@",error.description];
        complete(NO,errorCode,@{@"error":errorCode});
    }];

}

//验证码
+(void)sendDynCodePostURL:(NSString *)urlStr andPhoneNumber:(NSString *)number andType:(NSString *)type complete:(void(^)(BOOL succeed, NSString* ret, NSDictionary * dictionary))complete{

    NSDictionary *parameters = @{@"phone":number, @"type":type};
      [self requestNetWorkURL:urlStr parameters:parameters progress:nil success:nil failure:nil complete:complete];

}

+(void)testDynCodePostURL:(NSString *)urlStr andPhoneNumber:(NSString *)number andCode:(NSString *)code complete:(void(^)(BOOL succeed,NSString * ret, NSDictionary * dictionary))complete{
    
    NSDictionary *parameters = @{@"phone":number, @"code":code};
   [self requestNetWorkURL:urlStr parameters:parameters progress:nil success:nil failure:nil complete:complete];
}

//注册
+(void)registerPostURL:(NSString *)urlStr
        andPhoneNumber:(NSString *)number
             andRandom:(NSString *)token
                andPwd:(NSString *)passWord
               andType:(NSString *)type
          andHeadImage:(NSString *)headImage
           andNickName:(NSString *)nickName
            andUserSex:(NSString *)userSex
            andUserAge:(NSInteger)userAge
         andMovieLabel:(NSString *)movieLabel
       andInviterPhone:(NSString *)inviterPhone
                andMac:(NSString *)mac
               andImsi:(NSString *)imsi
         andSystemName:(NSString *)systemName
      andSystemVersion:(NSString *)systemVersion
              complete:(void(^)(BOOL succeed, NSString * ret, NSDictionary * dictionary))complete
{
    NSString *passWordstr = [passWord stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];

    NSString *Md5Password = passWordstr;

    NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
    [parameters setValue:number?number:@"" forKey:@"phone"];
    [parameters setValue:token?token:@"" forKey:@"random"];
    [parameters setValue:Md5Password?Md5Password:@"" forKey:@"pwd"];
    [parameters setValue:type?type:@"" forKey:@"type"];
    [parameters setValue:headImage?headImage:@"" forKey:@"headImage"];
    [parameters setValue:nickName?nickName:@"" forKey:@"nickName"];
    [parameters setValue:userSex?userSex:@"" forKey:@"userSex"];
    [parameters setValue:[NSString stringWithFormat:@"%ld", (long)userAge] forKey:@"userAge"];
    [parameters setValue:movieLabel?movieLabel:@"" forKey:@"movieLabel"];
    [parameters setValue:inviterPhone?inviterPhone:@"" forKey:@"inviterPhone"];
    [parameters setValue:mac?mac:@"" forKey:@"mac"];
    [parameters setValue:imsi?imsi:@"" forKey:@"imsi"];
    [parameters setValue:systemName?systemName:@"" forKey:@"systemName"];
    [parameters setValue:systemVersion?systemVersion:@"" forKey:@"systemVersion"];

    [self requestNetWorkURL:urlStr parameters:parameters progress:nil success:nil failure:nil complete:complete];
}

//登录
+(void)loginPostURL:(NSString *)urlStr
     andphoneNumber:(NSString *)phoneNumber
             andPwd:(NSString *)passWord
            andType:(NSString *)type
             andMac:(NSString *)mac
            andImsi:(NSString *)imsi
      andSystemName:(NSString *)systemName
   andSystemVersion:(NSString *)systemVersion
      andDeviceToke:(NSString *)deviceToken
      andDeviceType:(NSString *)deviceType
           complete:(void(^)(BOOL succeed, NSString * ret, NSDictionary * dictionary))complete{
    
        NSString *passWordstr = [passWord stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
        NSString *Md5Password = passWordstr;
        NSDictionary *parameters = @{@"phone":phoneNumber, @"pwd":Md5Password, @"type":type, @"mac":mac, @"imsi":imsi, @"systemName":systemName, @"systemVersion":systemVersion, @"deviceToken":deviceToken, @"deviceType":deviceType};
        [self requestNetWorkURL:urlStr parameters:parameters progress:nil success:nil failure:nil complete:complete];

}


//验证码登录
+(void)loginPostURLPhoneCode:(NSString *)urlStr
     andphoneNumber:(NSString *)phoneNumber
             andCode:(NSString *)code
            andType:(NSString *)type
             andMac:(NSString *)mac
            andImsi:(NSString *)imsi
      andSystemName:(NSString *)systemName
   andSystemVersion:(NSString *)systemVersion
      andDeviceToke:(NSString *)deviceToken
      andDeviceType:(NSString *)deviceType
           complete:(void(^)(BOOL succeed, NSString * ret, NSDictionary * dictionary))complete{
    
//    NSString *passWordstr = [passWord stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
//    NSString *Md5Password = passWordstr;
    NSDictionary *parameters = @{@"phone":phoneNumber, @"code":code, @"type":type, @"mac":mac, @"imsi":imsi, @"systemName":systemName, @"systemVersion":systemVersion, @"deviceToken":deviceToken, @"deviceType":deviceType};
    [self requestNetWorkURL:urlStr parameters:parameters progress:nil success:nil failure:nil complete:complete];
    
}

//忘记、修改密码
+(void)changePasswordPostURL:(NSString *)urlStr
              andphoneNumber:(NSString *)phoneNumber
                     andCode:(NSString *)code
                      andPwd:(NSString *)passWord
                    complete:(void(^)(BOOL succeed, NSString * ret, NSDictionary * dictionary))complete{
     NSString *passWordstr = [passWord stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
    NSString *Md5Password = passWordstr;
        NSDictionary *parameters = @{@"phone":phoneNumber, @"code":code, @"pwd":Md5Password};
    [self requestNetWorkURL:urlStr parameters:parameters progress:nil success:nil failure:nil complete:complete];
  

}


//获取用户信息
+(void)requsetUseMessagePostUrl:(NSString *)urlStr
                       complete:(void(^)(BOOL succeed, NSString * ret, NSDictionary * dictionary))complete{
    NSDictionary *parameters = @{};
    [self requestNetWorkURL:urlStr parameters:parameters progress:nil success:nil failure:nil complete:complete];
            
}

//请求电影
+(void)requestMoviesPOST:(NSString *)urlStr
                 andPage:(NSInteger ) page
             andPageSize:(NSInteger )pageSize
                complete:(void(^)(BOOL succeed, NSString * ret, NSDictionary * dictionary))complete{
    
    NSDictionary *parameters = @{@"page":[NSNumber numberWithInteger:page],@"pageSize":[NSNumber numberWithInteger:pageSize]};
    
    [self requestNetWorkURL:urlStr parameters:parameters progress:nil success:nil failure:nil complete:complete];

}

//影片详情列表
+(void)requestMoviesListPOST:(NSString *)urlStr
                     andPage:(NSInteger )page
                 andPageSize:(NSInteger )pageSize
                  andCurCity:(NSString *)curCity
                    andCurJd:(NSString *)curJd
                    andCurWd:(NSString *)curWd
                  andSexType:(NSString *)sexType
                 andSortType:(NSString *)sortType
                  andSortVal:(NSString *)sortVal
                  andReqTime:(NSString *)reqTime
                  andMovieId:(NSString *)movieId
                    complete:(void(^)(BOOL succeed, NSString * ret, NSDictionary * dictionary))complete{

    NSDictionary *parameters = @{@"page":@(page), @"pageSize":@(pageSize), @"curCity":curCity, @"curJd":curJd, @"curWd":curWd, @"sexType":sexType, @"sortType":sortType, @"sortVal":sortVal, @"reqTime":reqTime, @"movieId":movieId};
    [self requestNetWorkURL:urlStr parameters:parameters progress:nil success:nil failure:nil complete:complete];
}
//影片详情
+(void)requestMoviesDetailPostURL:(NSString *)urlStr
                         andAppId:(NSString *)AppId
                         complete:(void(^)(BOOL succeed, NSString * ret, NSDictionary * dictionary))complete{

    NSDictionary *parameters = @{@"AppId":AppId};
    [self requestNetWorkURL:urlStr parameters:parameters progress:nil success:nil failure:nil complete:complete];

}
/*
 AppId	必填	String	影约ID
 title	必填	String	影约标题
 meetTime	必填	Integer	见面时间
 meetAddress	必填	Integer	见面地点
 needVerified	选填	String	是否需要实名认证
 takePeople	选填	String	影约人带外挂
 phone	必填	String	影约人电话(默认自己的注册账号，但是有可能修改)
 plan	必填	String	影约计划
 releaseAddress	必填	String	发布地点，后台根据此进行地区的筛选
 jd	必填	String	经度
 wd	必填	String	纬度
 moivieId	选填	String	影片ID，关联的影片
 
 
 ret	"返回码
 请求成功
 已被限制发单
 此地区未开放
 权限问题，不是自己的影约"
 */
//编辑影约
+(void)requestEditMovieMeetPostURL:(NSString *)urlStr
                         andAppId:(NSString *)appId
                         andTitle:(NSString *)title
                      andmeetTime:(NSInteger)meetTime
                   andmeetAddress:(NSString *)meetAddress
                  andneedVerified:(NSString *)needVerified
                    andTakePeople:(NSString *)takePeople
                         andPhone:(NSString *)phone
                          andPlan:(NSString *)plan
                andReleaseAddress:(NSString *)releaseAddress
                            andJd:(NSString *)jd
                            andWd:(NSString *)wd
                       andMovieId:(NSString *)movieId
                         complete:(void(^)(BOOL succeed, NSString * ret, NSDictionary * dictionary))complete{
    NSDictionary *parameters = @{@"AppId":movieId,@"title":title,@"meetTime":@(meetTime),@"meetAddress":meetAddress,@"needVerified":needVerified,@"takePeople":takePeople,@"phone":phone,@"plan":plan,@"releaseAddress":releaseAddress,@"jd":jd,@"wd":wd,@"movieId":movieId};
    [self requestNetWorkURL:urlStr parameters:parameters progress:nil success:nil failure:nil complete:complete];

}

//发布影约
+(void)requestReleaseMovieMeetPostURL:(NSString *)urlStr
                             andTitle:(NSString *)title
                       andMeetAddress:(NSString *)meetAddress
                      andNeedVerified:(NSInteger)needVerified
                        andTakePeople:(NSInteger)takePeople
                             andPhone:(NSString *)phone
                    andReleaseAddress:(NSString *)releaseAddress
                                andJd:(NSString *)jd
                                andWd:(NSString *)wd
                           andPayType:(NSString *)payType
                           andMovieId:(NSString *)movieId
                          andMeetTime:(NSString *)meetTime
                              andPlan:(NSString *)plan
                             complete:(void(^)(BOOL succeed, NSString * ret, NSDictionary * dictionary))complete{
    NSDictionary *parameters = @{@"title":title,@"meetAddress":meetAddress,@"needVerified":@(needVerified),@"takePeople":@(takePeople),@"phone":phone,@"releaseAddress":releaseAddress,@"jd":jd,@"wd":wd,@"payType":payType,@"movieId":movieId,@"meetTime":meetTime,@"plan":plan};
    [self requestNetWorkURL:urlStr parameters:parameters progress:nil success:nil failure:nil complete:complete];
    
}

//消息
+ (void)requestMessageListGetUrl:(NSString *)urlStr
                         andPage:(NSInteger)page
                     andPageSize:(NSInteger)pageSize
                       msgStatus:(NSString *)msgStatus
                        complete:(void(^)(BOOL succeed, NSString * ret, NSDictionary * dictionary))complete
{
    NSDictionary *parameters = @{@"page":@(page), @"pageSize":@(pageSize), @"msgStatus":msgStatus};
    [self requestGETNetWorkURL:SocialMessageIP parameters:parameters complete:complete];
}

//喜欢
+(void)requestLikeListPostUrl:(NSString *)urlStr
                      andPage:(NSInteger)page
                  andPageSize:(NSInteger)pageSize
                     complete:(void(^)(BOOL succeed, NSString * ret, NSDictionary * dictionary))complete{

    NSDictionary *parameters = @{@"page":@(page),@"pageSize":@(pageSize)};
    [self requestNetWorkURL:urlStr parameters:parameters progress:nil success:nil failure:nil complete:complete];

}

//上传用户图片
+(void)uploadingUserPicImagePostUrl:(NSString *)urlStr
                            imgName:(NSString *)imgName
                            imgData:(NSString *)imgData
                              title:(NSString *)title
                               type:(NSString *)type
                           complete:(void(^)(BOOL succeed, NSString * ret, NSDictionary * dictionary))complete{
    NSDictionary *parameters = @{@"imgName":imgName,@"imgData":imgData,@"title":title,@"type":type};
    [self requestNetWorkURL:urlStr parameters:parameters progress:nil success:nil failure:nil complete:complete];

}
//获取用户图片
+(void)getImageUserPicImageGetUrl:(NSString *)urlStr
                              fid:(NSInteger)fid
                         complete:(void(^)(BOOL succeed, NSString * ret, NSDictionary * dictionary))complete{
    
    NSDictionary *parameters = @{@"fid":@(fid)};
    [self requestGETNetWorkURL:urlStr parameters:parameters complete:complete];
  
}


//设置用户头像 前台只需要上传fid 告诉那张图片是头像  主要由后台操作
+(void)settingUserHeadImagePostUrl:(NSString *)urlStr
                               fid:(NSInteger)fid
                          complete:(void(^)(BOOL succeed, NSString * ret, NSDictionary * dictionary))complete{
    NSDictionary *parameters = @{@"fid":@(fid)};
    [self requestNetWorkURL:urlStr parameters:parameters progress:nil success:nil failure:nil complete:complete];


}

//设置用户相册图片 前台只需要上传fid 告诉那张图片是头像  主要由后台操作
+(void)settingUserAlbumImagePostUrl:(NSString *)urlStr
                            albumId:(NSInteger)albumId
                                uid:(NSInteger)uid
                         albumTitle:(NSString *)albumTitle
                       albumContent:(NSString *)albumContent
                           complete:(void(^)(BOOL succeed, NSString * ret, NSDictionary * dictionary))complete{

    NSDictionary *parameters =  @{@"albumList":[NSString stringWithFormat:@"[{\"albumId\":%ld,\"uid\":%ld,\"albumTitle\":\"%@\",\"albumContent\":\"%@\"}]", (long)albumId, (long)uid, albumTitle, albumContent]};
    [self requestNetWorkURL:urlStr parameters:parameters progress:nil success:nil failure:nil complete:complete];
}

//设置用户相册图片 前台只需要上传fid 告诉那张图片是头像  主要由后台操作
+(void)settingUserAlbumImagePostUrl:(NSString *)urlStr
                          albumJson:(NSString *)albumJson
                           complete:(void(^)(BOOL succeed, NSString * ret, NSDictionary * dictionary))complete{
    
    NSDictionary *parameters =  @{@"albumList":albumJson};
    [self requestNetWorkURL:urlStr parameters:parameters progress:nil success:nil failure:nil complete:complete];
}

//获取账户相册
+(void)getUserAlbumImagePostUrl:(NSString *)urlStr
                                uid:(NSInteger)uid
                           complete:(void(^)(BOOL succeed, NSString * ret, NSDictionary * dictionary))complete{
    NSDictionary *parameters = @{@"uid":@(uid)};
 [self requestNetWorkURL:urlStr parameters:parameters progress:nil success:nil failure:nil complete:complete];

}
//删除账户相册
+(void)deleteUserAlbumImagePostUrl:(NSString *)urlStr
                           albumId:(NSInteger)albumId
                          complete:(void(^)(BOOL succeed, NSString * ret, NSDictionary * dictionary))complete{
    NSDictionary *parameters = @{@"albumId":@(albumId)};
    [self requestNetWorkURL:urlStr parameters:parameters progress:nil success:nil failure:nil complete:complete];

}

//账户信息修改保存
+(void)upDataUserMessagePostUrl:(NSString *)urlStr
                            uid:(NSInteger)uid
                          token:(NSString *)token
                       nickName:(NSString *)nickName
                        userSex:(NSString *)userSex
                      signature:(NSString *)signature
                        userAge:(NSString *)userAge
                     movieLabel:(NSString *)movieLabel
                   oftenAddress:(NSString *)oftenAddress
                      loveMovie:(NSString *)loveMovie
                   professional:(NSString *)professional
                      userSkill:(NSString *)userSkill
                       complete:(void(^)(BOOL succeed, NSString * ret, NSDictionary * dictionary))complete{
    NSDictionary *parameters = @{@"uid":@(uid),@"token":token,@"nickName":nickName,@"userSex":userSex,@"signature":signature,@"userAge":userAge,@"movieLabel":movieLabel,@"oftenAddress":oftenAddress,@"loveMovie":loveMovie,@"professional":professional,@"professional":professional};
    [self requestNetWorkURL:urlStr parameters:parameters progress:nil success:nil failure:nil complete:complete];
}


//首页用户列表
+(void)requestFirstUserListPostUrl:(NSString *)urlStr
                              page:(NSInteger)page
                          pageSize:(NSInteger)pageSize
                             curJd:(double)curJd
                             curWd:(double)curWd
                           userSex:(NSString *)userSex
                          complete:(void(^)(BOOL succeed, NSString * ret, NSDictionary * dictionary))complete{
    
        NSDictionary *parameters = @{@"page":@(page),@"pageSize":@(pageSize),@"curJd":@(curJd),@"curWd":@(curWd),@"userSex":userSex};

        [self requestNetWorkURL:urlStr parameters:parameters progress:nil success:nil failure:nil complete:complete];
    
}


//网络判断
+(void)netWorkReachabillity{
  

}

//获取用户信息
+(void)requsetUseMessagePostUrl:(NSString *)urlStr uid:(NSString *)uid complete:(void(^)(BOOL succeed, NSString * ret, NSDictionary * dictionary))complete {
    NSDictionary *parameters = @{@"uid":uid};
    [self requestNetWorkURL:urlStr parameters:parameters progress:nil success:nil failure:nil complete:complete];
    
}

#pragma mark - 社交

//喜欢接口
+ (void)requestLikeInterface:(NSString *)urlStr toUid:(NSInteger)toUid complete:(void(^)(BOOL succeed, NSString * ret, NSDictionary * dictionary))complete
{
    NSDictionary *parameters = @{@"toUid":@(toUid)};
    [self requestNetWorkURL:LikeInterface parameters:parameters progress:nil success:nil failure:nil complete:complete];
}

//关注接口
+ (void)requestCollection:(NSString *)urlStr toUid:(NSInteger)toUid complete:(void(^)(BOOL succeed, NSString * ret, NSDictionary * dictionary))complete
{
    NSDictionary *parameters = @{@"toUid":@(toUid)};
    [self requestNetWorkURL:MY_COLLECTION_List parameters:parameters progress:nil success:nil failure:nil complete:complete];
}

//关注列表接口
+ (void)requestCollectionList:(NSString *)urlStr page:(NSInteger)page pageSize:(NSInteger)pageSize complete:(void(^)(BOOL succeed, NSString * ret, NSDictionary * dictionary))complete
{
    //进入网络请求
    NSLog(@"进入网络请求");
    NSDictionary *parameters = @{@"page":@(page), @"pageSize":@(pageSize)};
    [self requestNetWorkURL:collectListIP parameters:parameters progress:nil success:nil failure:nil complete:complete];
}

//取消关注操作
+ (void)requestDeleteCollection:(NSString *)urlStr toUid:(NSString *)toUid complete:(void(^)(BOOL succeed, NSString * ret, NSDictionary * dictionary))complete {
    NSDictionary *parameters = @{@"toUid":toUid};
    [self requestNetWorkURL:deleteCollection_interface parameters:parameters progress:nil success:nil failure:nil complete:complete];
}

//我的发布列表接口
+ (void)requestMyReleaseMovieList:(NSString *)urlStr page:(NSInteger)page pageSize:(NSInteger)pageSize complete:(void(^)(BOOL succeed, NSString * ret, NSDictionary * dictionary))complete
{
    NSDictionary *parameters = @{@"page":@(page), @"pageSize":@(pageSize)};
    [self requestNetWorkURL:MY_Release_MovieList parameters:parameters progress:nil success:nil failure:nil complete:complete];
}

//确认约会列表接口
+ (void)requestMyConfirmMovieList:(NSString *)urlStr page:(NSInteger)page pageSize:(NSInteger)pageSize appId:(NSString *)appId releaseTime:(NSString *)releaseTime complete:(void(^)(BOOL succeed, NSString * ret, NSDictionary * dictionary))complete
{
    NSDictionary *parameters = @{@"page":@(page), @"pageSize":@(pageSize), @"appId":appId, @"releaseTime":releaseTime};
    [self requestNetWorkURL:MY_Accept_MovieList parameters:parameters progress:nil success:nil failure:nil complete:complete];
}

//确认约会接口
+ (void)requestConfirm:(NSString *)urlStr appId:(NSString *)appId releaseTime:(NSString *)releaseTime acceptUid:(NSInteger)acceptUid complete:(void(^)(BOOL succeed, NSString * ret, NSDictionary * dictionary))complete
{
    NSDictionary *parameters = @{@"acceptUid":@(acceptUid), @"appId":appId, @"releaseTime":releaseTime};
    [self requestNetWorkURL:confirmSure parameters:parameters progress:nil success:nil failure:nil complete:complete];
}

//成功约会列表接口
+ (void)requestMySuccessMovieList:(NSString *)urlStr page:(NSInteger)page pageSize:(NSInteger)pageSize complete:(void(^)(BOOL succeed, NSString * ret, NSDictionary * dictionary))complete {
    NSDictionary *parameters = @{@"page":@(page), @"pageSize":@(pageSize)};
    [self requestNetWorkURL:MY_Success_MovieList parameters:parameters progress:nil success:nil failure:nil complete:complete];
}

//等待约会列表接口
+ (void)requestMyConfirmMovieList:(NSString *)urlStr page:(NSInteger)page pageSize:(NSInteger)pageSize complete:(void(^)(BOOL succeed, NSString * ret, NSDictionary * dictionary))complete{
    NSDictionary *parameters = @{@"page":@(page), @"pageSize":@(pageSize)};
    [self requestNetWorkURL:MY_Confirm_MovieList parameters:parameters progress:nil success:nil failure:nil complete:complete];
}

//取消等待确认中影约接口
+(void)cancleAcceptMovieURl:(NSString *)url appId:(NSString *)appId releaseTime:(NSString *)releaseTime complete:(void(^)(BOOL succeed, NSString * ret, NSDictionary * dictionary))complete{
    NSDictionary *parameters = @{ @"appId":appId, @"releaseTime":releaseTime};
    [self requestNetWorkURL:cancelAccept_MovieDate parameters:parameters progress:nil success:nil failure:nil complete:complete];
}

//取消、删除已发布影约
+(void)setMovieStatusURl:(NSString *)url objId:(NSString *)objUid status:(NSString *)status complete:(void(^)(BOOL succeed, NSString * ret, NSDictionary * dictionary))complete {
    NSDictionary *parameters = @{@"objId":objUid, @"status":status};
    [self requestNetWorkURL:MY_deleteRelease parameters:parameters progress:nil success:nil failure:nil complete:complete];
}

//编辑已发布的影约
+(void)updateReleaseMovieDateURl:(NSString *)url
                           AppId:(NSString *)AppId
                           title:(NSString *)title
                        meetTime:(NSString *)meetTime
                     meetAddress:(NSString *)meetAddress
                    needVerified:(NSInteger)needVerified
                      takePeople:(NSString *)takePeople
                           phone:(NSString *)phone
                            plan:(NSString *)plan
                  releaseAddress:(NSString *)releaseAddress
                              jd:(NSString *)jd
                              wd:(NSString *)wd
                        moivieId:(NSString *)moivieId
                        payType:(NSString *)payType
                        complete:(void(^)(BOOL succeed, NSString * ret, NSDictionary * dictionary))complete{

    NSDictionary *parameters = @{@"AppId":AppId,@"title":title,@"meetAddress":meetAddress,@"needVerified":@(needVerified),@"takePeople":takePeople,@"phone":phone,@"releaseAddress":releaseAddress,@"jd":jd,@"wd":wd,@"meetTime":meetTime,@"plan":plan,@"moivieId":moivieId,@"payType":payType};

    [self requestNetWorkURL:url parameters:parameters progress:nil success:nil failure:nil complete:complete];


}
+ (NSString*)dictionaryToJson:(NSDictionary *)dic

{
    
    NSError *parseError = nil;
    
    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dic options:NSJSONWritingPrettyPrinted error:&parseError];
    
    return [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    
}
//赞操作
+ (void)requestZambia:(NSString *)urlStr toUid:(NSString *)toUid complete:(void(^)(BOOL succeed, NSString * ret, NSDictionary * dictionary))complete {
    NSDictionary *parameters = @{@"toUid":toUid};
    [self requestNetWorkURL:zambia_interface parameters:parameters progress:nil success:nil failure:nil complete:complete];
}

//我要应约接口
+ (void)requestAccept:(NSString *)urlStr acceptTime:(NSString *)acceptTime acceptAddress:(NSString *)acceptAddress appId:(NSString *)appId releaseTime:(NSString *)releaseTime complete:(void(^)(BOOL succeed, NSString * ret, NSDictionary * dictionary))complete
{
    NSDictionary *parameters = @{@"acceptTime":acceptTime, @"acceptAddress":acceptAddress, @"appId":appId, @"releaseTime":releaseTime};
    [self requestNetWorkURL:MY_Accept parameters:parameters progress:nil success:nil failure:nil complete:complete];
}

//验证
+ (void)requestActivate:(NSString *)token complete:(void(^)(BOOL succeed, NSString * ret, NSDictionary * dictionary))complete
{
    NSDictionary *parameters = @{@"token":token};
    NSLog(@"sadsadasd"); 
    [self requestNetWorkURL:activate_interface parameters:parameters progress:nil success:nil failure:nil complete:complete];
}

//标签列表
+(void)requestMovieLabelList:(NSString *)urlStr page:(NSInteger )page pageSize:(NSInteger )pageSize type:(NSInteger)type complete:(void(^)(BOOL succeed, NSString * ret, NSDictionary * dictionary))complete{
 
    NSDictionary *parameters = @{@"page":@(page),@"pageSize":@(pageSize),@"type":@(type)};
    [self requestGETNetWorkURL:urlStr parameters:parameters complete:complete];
    
}
//添加标签
+(void)insertLabel:(NSString *)urlStr name:(NSString *)name type:(NSInteger)type complete:(void(^)(BOOL succeed, NSString * ret, NSDictionary * dictionary))complete{
         NSDictionary *parameters = @{@"name":name,@"type":@(type)};
        [self requestGETNetWorkURL:urlStr parameters:parameters complete:complete];
}

//修改标签
+(void)updateUserLabel:(NSString *)urlStr userLabels:(NSMutableArray *)userLabels complete:(void(^)(BOOL succeed, NSString * ret, NSDictionary * dictionary))complete{
    NSString *str = @"";
    for (int i = 0; i < userLabels.count; i ++) {
        if (i == 0) {
            str = [userLabels objectAtIndex:0];
        } else {
            str = [NSString stringWithFormat:@"%@,%@", str, [userLabels objectAtIndex:i]];
        }
    }
    
     NSDictionary *parameters =  @{@"userLabels":str};
     [self requestGETNetWorkURL:urlStr parameters:parameters complete:complete];
}

//举报接口
+ (void)inform:(NSString *)urlStr associationObj:(NSString *)associationObj passiveObj:(NSString *)passiveObj appTime:(NSString *)appTime complete:(void(^)(BOOL succeed, NSString * ret, NSDictionary * dictionary))complete {
    NSMutableDictionary *dict = [NSMutableDictionary dictionary];
    [dict setValue:associationObj forKey:@"associationObj"];
    [dict setValue:passiveObj forKey:@"passiveObj"];
    [dict setValue:appTime forKey:@"appTime"];
    [dict setValue:@"2" forKey:@"rbType"];
    
    [self requestGETNetWorkURL:urlStr parameters:dict complete:complete];
}

//加入黑名单
+ (void)requestAddBlackList:(NSString *)urlStr toUid:(NSString *)toUid complete:(void(^)(BOOL succeed, NSString * ret, NSDictionary * dictionary))complete {
    NSDictionary *parameters = @{@"toUid":toUid};
    [self requestNetWorkURL:setBlackList_interface parameters:parameters progress:nil success:nil failure:nil complete:complete];
}

//移除黑名单
+ (void)requestDeleteBlackList:(NSString *)urlStr toUid:(NSString *)toUid complete:(void(^)(BOOL succeed, NSString * ret, NSDictionary * dictionary))complete {
    NSDictionary *parameters = @{@"toUid":toUid};
    [self requestNetWorkURL:deleteBlackList_interface parameters:parameters progress:nil success:nil failure:nil complete:complete];
}

//黑名单列表
+ (void)requestGetBlackList:(NSString *)urlStr
                     andPage:(NSInteger)page
                 andPageSize:(NSInteger)pageSize
                    complete:(void(^)(BOOL succeed, NSString * ret, NSDictionary * dictionary))complete
{
    NSDictionary *parameters = @{@"page":@(page), @"pageSize":@(pageSize)};
    [self requestGETNetWorkURL:getBlackList_interface parameters:parameters complete:complete];
}


//电影票列表
+ (void)requestGetPrizesListPage:(NSInteger)page
                     andPageSize:(NSInteger)pageSize
                          status:(NSString *)status
                        complete:(void(^)(BOOL succeed, NSString * ret, NSDictionary * dictionary))complete
{
    NSDictionary *parameters = @{@"page":@(page), @"pageSize":@(pageSize), @"state":status};
    [self requestGETNetWorkURL:getPrizesList_interface parameters:parameters complete:complete];
}

//领取电影票
+ (void)requestReceivePrize:(NSString *)ticketid complete:(void(^)(BOOL succeed, NSString * ret, NSDictionary * dictionary))complete {
    NSDictionary *parameters = @{@"receivePrizeId":ticketid};
    [self requestNetWorkURL:receivePrize_interface parameters:parameters progress:nil success:nil failure:nil complete:complete];
}


@end
